summaryrefslogtreecommitdiffstats
path: root/src/common/vector_math.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/vector_math.h')
-rw-r--r--src/common/vector_math.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/common/vector_math.h b/src/common/vector_math.h
index 0e2095c45..b4885835d 100644
--- a/src/common/vector_math.h
+++ b/src/common/vector_math.h
@@ -259,6 +259,20 @@ public:
return *this;
}
+ void RotateFromOrigin(float roll, float pitch, float yaw) {
+ float temp = y;
+ y = std::cos(roll) * y - std::sin(roll) * z;
+ z = std::sin(roll) * temp + std::cos(roll) * z;
+
+ temp = x;
+ x = std::cos(pitch) * x + std::sin(pitch) * z;
+ z = -std::sin(pitch) * temp + std::cos(pitch) * z;
+
+ temp = x;
+ x = std::cos(yaw) * x - std::sin(yaw) * y;
+ y = std::sin(yaw) * temp + std::cos(yaw) * y;
+ }
+
[[nodiscard]] constexpr T Length2() const {
return x * x + y * y + z * z;
}